﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZX.OA.Model;
using System.Data.Entity;

namespace ZX.OA.DAL
{
    public class MessageInfoDAL
    {
        Entity entity = new Entity();
        public List<MessageInfo>ShowMessage()
        {
            return entity.MessageInfo.ToList();
        }
        public int AddMessage(MessageInfo m)
        {
            entity.MessageInfo.Add(m);
            return entity.SaveChanges();
        }
        public int DeleteMessage(int id)
        {
           entity.MessageInfo.Remove(entity.MessageInfo.Find(id));
            return entity.SaveChanges();
        }
        public MessageInfo GetMessageByMessageID(int messageid)
        {
            return entity.MessageInfo.Find(messageid);
        }
        public int UpdMessageByMessageID(MessageInfo m)
        {
            entity.Entry(m).State = System.Data.EntityState.Modified;
            return entity.SaveChanges();
        }
        /// <summary>
        /// 修改信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public int UpdateMessage(MessageInfo m)
        {
            entity.Entry(m).State = System.Data.EntityState.Modified;
            return entity.SaveChanges();
        }
    }
}
